package Map_jihe;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class map_api {
    public static void main(String[] args) {
        Map<String,Integer> a=new HashMap<>();
        a.put("朱佳铖",18);
        a.put("李佳辉",18);
        a.put("杨杨",17);
        a.put("狗哥",21);
        System.out.println(a);
        //1.清空集合
//        a.clear();
//        System.out.println(a);
        //2.判断是否为空
        System.out.println(a.isEmpty());//false
        //3.用键获取值
        System.out.println(a.get("朱佳铖"));
        //4.用键删除元素
        System.out.println(a.remove("朱佳铖"));//18
        a.put("朱佳铖",18);
        //5.判断是否包含某个键
        System.out.println(a.containsKey("朱佳铖"));//true
        //6.判断是否包含某个值
        System.out.println(a.containsValue(18));//true
        //7.用集合获取键
        Set<String> key=a.keySet();
        System.out.println(key);//[狗哥, 李佳辉, 朱佳铖, 杨杨]
        //8.集合大小
        System.out.println(a.size());//4
        //9合并map
        Map<String,Integer> b=new HashMap<>();
        b.put("启动器",99999);
        a.putAll(b);
        System.out.println(a);//{狗哥=21, 李佳辉=18, 朱佳铖=18, 启动器=99999, 杨杨=17}
    }
}
